package com.chaos.framework.starter.config.thread;

import com.chaos.framework.model.helper.TraceHelper;

import java.util.concurrent.*;

/**
 * @author: liucw
 * @createDate: 2022/11/9
 * @description:
 */
public class MdcThreadPoolExecutor extends ThreadPoolExecutor {

    public MdcThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler) {
        super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler);
    }

    @Override
    public void execute(Runnable command) {
        super.execute(TraceHelper.wrapper(command));
    }

    @Override
    public <T> Future<T> submit(Runnable task, T result) {
        return super.submit(TraceHelper.wrapper(task), result);
    }

    @Override
    public Future<?> submit(Runnable task) {
        return super.submit(TraceHelper.wrapper(task));
    }

    @Override
    public <T> Future<T> submit(Callable<T> task) {
        return super.submit(TraceHelper.wrapper(task));
    }


}
